package com.itao.rabbitmq.listener;

import com.itao.rabbitmq.entity.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @Author sjt
 * @CreateTime 2023/09/27 16:15
 */
@Component
@Slf4j
public class MessageListener {

//    @RabbitListener(bindings = @QueueBinding(
//            value = @Queue(value = "delay.queue", durable = "true"),
//            exchange = @Exchange(value = "delay.exchange", type = "topic", delayed = "true"),
//            key = "delay"
//    ))

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(value = "direct.queue", durable = "true"),
            exchange = @Exchange(value = "direct.exchange", type = "direct"),
            key = "direct.test"
    )
    )
    public void getMessage(User user) {
        log.info("接收到消息{}", user);
        throw new RuntimeException("测试重试");
    }
}
